<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	  "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>User CMake configuration - deal.II</title>
    <link href="../screen.css" rel="StyleSheet">
    <meta name="author" content="the deal.II authors <authors @ dealii.org>">
    <meta name="copyright" content="Copyright (C) 2012 - 2020 by the deal.II authors">
    <meta name="keywords" content="deal.II">
  </head>

<body>
<h1>How to use CMake to configure your projects with <acronym>deal.II</acronym></h1>

<p>
  <code>cmake</code> is controlled by input files that by convention are
  called <code>CMakeLists.txt</code>, listing both configuration commands
  as well as dependencies between source files and targets.
  This page presents some <code>CMakeLists.txt</code> examples for
  potential use in your projects. (A detailed description of the
  <acronym>deal.II</acronym> project configuration is given in the
  <a href="cmake_dealii.html" target="body">deal.II CMake ReadMe</a>.)
</p>

<div class="toc">
  <ol>
    <li><a href="#cmakesimple">Simple <code>CMakeLists.txt</code></a>
      <ol>
        <li><a href="#cmakesimple.multiple">Adding multiple executable targets</a></li>
        <li><a href="#cmakesimple.libs">Adding libraries and common source files</a></li>
        <li><a href="#cmakesimple.build_type">Switching build types</a></li>
        <li><a href="#cmakesimple.run">Adding a "run" target</a></li>
      </ol>
    </li>
    <li><a href="#cmakeadvanced">Advanced <code>CMakeLists.txt</code></a>
      <ol>
        <li><a href="#cmakeadvanced.layout">Source directory layout</a></li>
        <li><a href="#cmakeadvanced.control">Control statements</a></li>
        <li><a href="#cmakeadvanced.globs">File globs</a></li>
        <li><a href="#cmakeadvanced.setup_target"><code>DEAL_II_SETUP_TARGET</code> revisited</a></li>
        <li><a href="#cmakeadvanced.cached_variables"><code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code> revisited</a></li>
        <li><a href="#cmakeadvanced.properties">Customizing include directories and compile definitions</a></li>
        <li><a href="#cmakeadvanced.external_libraries">External libraries</a></li>
        <li><a href="#cmakeadvanced.run">The "run" target revisited</a></li>
        <li><a href="#cmakeadvanced.install">Install a project</a></li>
      </ol>
    </li>
    <li><a href="#cmakeauto">Autopilot style <code>CMakeLists.txt</code></li>
    <li><a href="#dealiiconfig"><code>deal.IIConfig.cmake</code></a></li>
  </ol>
</div>

<a name="cmakesimple"></a>
<h2>Simple CMakeLists.txt</h2>

<p>
  In this section, we start out with a minimal <code>CMakeLists.txt</code>
  based on the <code>DEAL_II_SETUP_TARGET</code> macro. This method gives
  full control of what's happening and is easily extensible to more complex
  projects, as exemplified in the subsections here and later in the section
  on <a href="#cmakeadvanced">advanced topics</a>. Here is a full example
  (<a href="CMakeLists.txt.sample" target="_top">plain text</a>
  version):

<pre class="cmake">
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)

FIND_PACKAGE(deal.II 9.3.0 REQUIRED
  HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
  )
DEAL_II_INITIALIZE_CACHED_VARIABLES()

PROJECT(myproject)

ADD_EXECUTABLE(mycode mycode.cc)
DEAL_II_SETUP_TARGET(mycode)
</pre>

<p>
  The first line of this code makes sure that a sufficiently high
  version of CMake is installed. 2.8.8 is the minimal version required
  to set up <acronym>deal.II</acronym>, therefore it is safe to use this
  number here.
</p>

<p>
  Next, we find our deal.II installation with the help of the
  <code>FIND_PACKAGE</code> command. In this case requiring at least
  version 9.0.0. The <code>HINTS</code> are a list of directories where the
  install directory of deal.II is likely to be found. First, the location
  possibly defined in the CMake variable <code>DEAL_II_DIR</code> is
  considered. After that, we check whether we are in a subdirectory (first
  and second level) of the deal.II installation and otherwise use the
  environment variable <code>DEAL_II_DIR</code>. If all of these hints fail
  the default system locations <code>/usr/</code> and
  <code>/usr/local/</code> are considered. The list after
  <code>HINTS</code> can be changed according to your preferences.
</p>

<p>
  After finding the deal.II project, we fetch a set of cached variables
  with the <a href="#cmakeadvanced.cached_variables">
  <code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code></a> macro. You
  can inspect these for instance with <code>ccmake</code>.
</p>

<p>
  Every <code>CMakeLists.txt</code> must contain a project definition,
  which we do next.
</p>

<p>
  Finally, the last two lines define the executable that is to be produced
  and its source code. The <a href="#cmakeadvanced.setup_target">
  <code>DEAL_II_SETUP_TARGET</code></a> macro will set up necessary include
  directories, compile flags, compile definitions, link flags and the link
  interface.
</p>

<a name="cmakesimple.multiple"></a>
<h3>Adding multiple executable targets</h3>

<p>
  In order to specify multiple executable targets, simply repeat
  the last two lines of the simple <code>CMakeLists.txt</code>:
</p>

<pre class="cmake">
ADD_EXECUTABLE(mycode2 mycode2.cc)
DEAL_II_SETUP_TARGET(mycode2)

ADD_EXECUTABLE(mycode3 mycode3.cc)
DEAL_II_SETUP_TARGET(mycode3)
</pre>

If the list gets longer, consider using
a <a href="#cmakeadvanced.foreach">loop</a>, possibly
with <a href="#cmakeadvanced.globs">GLOB</a>.

    <a name="cmakesimple.libs"></a>
    <h3>Adding libraries and common source files</h3>

    <p>
      Adding a library is as simple as adding an executable target. We
      specify the library name and then have to tell cmake that the
      executables depend on it. The code in the simple file below the
      project definition accordingly changes for instance to:
    </p>

<pre class="cmake">
ADD_LIBRARY(mylib libsrc1.cc libsrc2.cc libsrc3.cc)
DEAL_II_SETUP_TARGET(mylib)

ADD_EXECUTABLE(mycode mycode.cc)
DEAL_II_SETUP_TARGET(mycode)
TARGET_LINK_LIBRARIES(mycode mylib)
</pre>

<p>When you have <a href="#cmakesimple.multiple">multiple targets</a>,
repeat the last line of code for each of them. Accordingly,
a <a href="#cmakeadvanced.foreach">loop</a> becomes even more
attractive.</p>

<p>If you only have a single file or few files with common source
code, an alternative to creating a library might be the option:</p>

<pre class="cmake">
ADD_EXECUTABLE(mycode mycode.cc common.cc)
DEAL_II_SETUP_TARGET(mycode)

ADD_EXECUTABLE(mycode2 mycode2.cc common.cc)
DEAL_II_SETUP_TARGET(mycode2)
</pre>

<p>You should be aware though that in this case <code>common.cc</code> will
be compiled for each target, not only once. If you want to avoid this and
still don't want to use a shared library or static archive, another option
is to create an <code>OBJECT</code> "library":</p>

<pre class="cmake">
ADD_LIBRARY(common OBJECT common.cc)
DEAL_II_SETUP_TARGET(common)

ADD_EXECUTABLE(mycode mycode.cc $&lt;TARGET_OBJECTS:common&gt;)
DEAL_II_SETUP_TARGET(mycode)

ADD_EXECUTABLE(mycode2 mycode2.cc $&lt;TARGET_OBJECTS:common&gt;)
DEAL_II_SETUP_TARGET(mycode2)
</pre>
This will compile <code>common.cc</code> once for the object target
<code>common</code> and link the resulting object file into the two
executables.

<a name="cmakesimple.build_type"></a>
<h3>Switching build types</h3>

<p> The build type is controlled via the variable
<code>CMAKE_BUILD_TYPE</code>. If it is set to <code>Debug</code>
executables and libraries specified in your <code>CMakeLists.txt</code>
file will be compiled in debug mode and linked against the debug version of
the deal.II library. Contrary, <code>Release</code> will build in optimized
mode and link against the optimized release version of deal.II. You can set
<code>CMAKE_BUILD_TYPE</code> with the help of <code>ccmake</code> or via
<code>cmake</code> on the command line: </p>

<pre class="cmake">
$ cmake -DCMAKE_BUILD_TYPE="Debug" .

$ cmake -DCMAKE_BUILD_TYPE="Release" .
</pre>

Alternatively, you can specify custom targets to switch the build type and
compile automatically:

<pre class="cmake">
ADD_CUSTOM_TARGET(debug
  COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
  COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
  )

ADD_CUSTOM_TARGET(release
  COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
  COMMENT "Switch CMAKE_BUILD_TYPE to Release"
  )
</pre>
With that, switching the build type and compiling the project can be done
very conveniently via:
<pre class="cmake">
$ make debug

$ make release
</pre>

<a name="cmakesimple.run"></a>
<h3>Adding a "run" target</h3>

<p> If you wish to have a "run" target for make, like in the deal.II
tutorial, specify one this way (obviously, a single "run" target can only
run a single executable): </p>

<pre class="cmake">
ADD_CUSTOM_TARGET(run COMMAND mycode
  COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration"
  )
</pre>


<a name="cmakeadvanced"></a>
<h2> Advanced <code>CMakeLists.txt</code></h2>

<p>This section covers some advanced topics for a user
<code>CMakeLists.txt</code> file.</p>

<a name="cmakeadvanced.layout"></a>
<h3>Source directory layout</h3>

<p>For complex projects it is desirable to organize source code and header
files in subdirectories. Assume the following project structure with a
library "mylib" and an executable "mycode":

<pre class="cmake">
mylib/source/*.cc
mylib/include/*.h

mycode/source/*.cc
mycode/include/*.h
</pre>

In this case the top level <code>CMakeLists.txt</code> file may be:
<pre class="cmake">
# top level CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
FIND_PACKAGE(deal.II 9.3.0 REQUIRED)

DEAL_II_INITIALIZE_CACHED_VARIABLES()
PROJECT(myproject)

ADD_SUBDIRECTORY(mylib)
ADD_SUBDIRECTORY(mycode)
</pre>
The <code>ADD_SUBDIRECTORY</code> statement will include the CMakeLists.txt
file in the specified subdirectory. In our case:

<pre class="cmake">
# mylib/CMakeLists.txt

INCLUDE_DIRECTORIES(include)

ADD_LIBRARY(mylib
  source/mylib1.cc
  source/mylib2.cc
  )

DEAL_II_SETUP_TARGET(mylib)
</pre>

We have to add the directory <code>include</code> for the header files to
the current include directories with the <code>INCLUDE_DIRECTORIES</code>
statement (see <a href="#cmakeadvanced.properties">this section</a> for
details). The corresponding configuration file for the executable looks
like:

<pre class="cmake">
# mycode/CMakeLists.txt

INCLUDE_DIRECTORIES(
  include
  ${CMAKE_SOURCE_DIR}/mylib/include
  )

ADD_EXECUTABLE(mycode source/mycode.cc)
DEAL_II_SETUP_TARGET(mycode)

TARGET_LINK_LIBRARIES(mycode mylib)
</pre>

<p>
Please note that <code>CMakeLists.txt</code> files have directory scope.
Any manipulation of properties and variables have only effect in the
current directory (and subdirectories, included with
<code>ADD_SUBDIRECTORY</code>. The level above will not be affected.
Therefore, we have to specify the include directories for "mylib" again in
the subdirectory <code>mycode</code> - this time with full path
<code>${CMAKE_SOURCE_DIR}/mylib/include</code>.
</p>

<p>
CMake defines the following variables for access to important directories:

<pre class="cmake">
CMAKE_SOURCE_DIR
  - the source directory (i.e. the directory of the top level
    CMakeLists.txt file)

CMAKE_BINARY_DIR
  - the (top level) build directory

CMAKE_CURRENT_SOURCE_DIR
  - the current source directory, i.e. location of the currently processed
    CMakeLists.txt file (top level or included via ADD_SUBDIRECTORY)

CMAKE_CURRENT_BINARY_DIR
  - the build (sub)directory corresponding to CMAKE_CURRENT_SOURCE_DIR
</pre>

</p>

<a name="cmakeadvanced.control"></a>
<h3>Control statements</h3>

<p>Control statements in CMake take the following form:
<pre class="cmake">
IF(&lt;expression&gt;)
  ...
ENDIF()
</pre>
or in long form:
<pre class="cmake">
IF(&lt;expression1&gt;)
  ...
ELSEIF(&lt;expression2&gt;)
  ...
ELSE()
  ...
ENDIF()
</pre>
Please note the (somehow uncommon) empty, opening and closing brackets
behind <code>ELSE()</code> and <code>ENDIF()</code>.
<code>&lt;expression&gt;</code> can take a multitude of different forms,
have a look at the
<a href="http://cmake.org/cmake/help/v2.8.8/cmake.html">CMake
documentation</a> for a complete list. Important examples are:
<pre class="cmake">
IF(${variable})
  - the body will be evaluated if the variable "variable" is defined and
    synonymous to true, e.g. 1, TRUE, ON, YES (modulo case insensitivity)

IF(variable MATCHES &lt;regular expression&gt;)
  - the body will be evaluated if the variable "variable" is defined and
    matches the specified regular expression

IF("${variable}" STREQUAL "foobar")
  - the body will be evaluated if both strings are equal. Note that
    "${variable}" will be replaced by the content of the (string)
    variable "variable"
</pre>
<p>An expression can be negated by prefixing <code>NOT</code>:</p>
<pre class="cmake">
IF(NOT &lt;expression&gt;)
  ...
ENDIF()
</pre>

<a name="cmakeadvanced.foreach"></a>
<p>Loops are implemented with the help of <code>WHILE</code> and
<code>FOR</code> statements. The former takes the same
<code>&lt;expression&gt;</code> as the <code>IF</code> statement:</p>
<pre class="cmake">
WHILE(&lt;expression&gt;)
  ...
ENDWHILE()
</pre>
Given a variable <code>list</code> containing a list, the individual
elements <code>element</code> can be accessed with a <code>FOREACH</code>
statement:
<pre class="cmake">
FOREACH(element ${list})
  ...
ENDFOREACH()
</pre>
Note: It is also possible to specify the list directly:
<pre class="cmake">
FOREACH(element foo bar baz)
  # The variable element will iterate through foo, bar and baz.
ENDFOREACH
</pre>


<a name="cmakeadvanced.globs"></a>
<h3>File globs</h3>

<p>A very common task is to pick up a list of source files from a
directory. You can either manage a list of source files in
<code>CMakeLists.txt</code> by hand, e.g. by manually updating all source
files for a given target, or you can use a glob to automate this process.
The following example will pick up every source file under
<code>SOURCE_DIR/sources/</code> and add it to an executable:</p>

<pre class="cmake">
FILE(GLOB sources ${CMAKE_SOURCE_DIR}/source/*.cc)
ADD_EXECUTABLE(mycode ${sources})
</pre>

<p>Please be aware of one caveat of this approach: Due to the fact that
CMake is a <i>build system generator</i> the resulting build configuration
(for make) has no way to detect whether a new source file was added (or
removed) and that it has to call back to cmake. So, after adding a new
source file you have to touch a <code>CMakeLists.txt</code> file or to run
<code>cmake .</code> again by hand.


<a name="cmakeadvanced.setup_target"></a>
<h3><code>DEAL_II_SETUP_TARGET</code> revisited</h3>
<p>
  The <code>DEAL_II_SETUP_TARGET</code> macro is responsible for setting up
  a target to compile and link against deal.II. It will <i>append</i> the
  <code>INCLUDE_DIRECTORIES</code> property with the location of the
  deal.II include directories, and <i>append</i> the properties
  <code>COMPILE_FLAGS</code>, <code>COMPILE_DEFINITIONS</code> and
  <code>LINK_FLAGS</code> by their respective values from the deal.II
  configuration (depending on build type and available debug and/or
  optimized flavor of the library).
</p>
<p>
  Except in the case of an object library, the specified target will also
  be set up to link against deal.II (and its transitive link interface) as
  well.
</p>

<p>
  Optionally, the <code>DEAL_II_SETUP_TARGET</code> macro takes an
  additional argument <code>DEBUG</code>, or <code>RELEASE</code>, after
  the target name to explicitly state the library flavor the target should
  be set up for. If the parameter is omitted, the correct choice is deduced
  from the current build type. (This is supported for the build types
  <code>Debug</code>, and <code>Release</code>. In case of
  <code>DebugRelease</code> the additional argument is always required.)
</p>

<p>
  Note: The flags that are added with <code>DEAL_II_SETUP_TARGET</code> to
  the target come last in the final link compiler invocation, or linker
  invocation. This means they take precedence over all flags defined via
  globally via <code>CMAKE_CXX_FLAGS</code>, etc., or as a directory
  property. If you wish to modify flags or preprocessor definitions set up
  with <code>DEAL_II_SETUP_TARGET</code> modify one of the following
  variables (see the section about <a
    href="#dealiiconfig"><code>deal.IIConfig.cmake</code></a> for
  details):
<pre class="cmake">
DEAL_II_CXX_FLAGS
DEAL_II_CXX_FLAGS_DEBUG
DEAL_II_CXX_FLAGS_RELEASE
DEAL_II_LINKER_FLAGS
DEAL_II_LINKER_FLAGS_DEBUG
DEAL_II_LINKER_FLAGS_RELEASE
DEAL_II_USER_DEFINITIONS
DEAL_II_USER_DEFINITIONS_DEBUG
DEAL_II_USER_DEFINITIONS_RELEASE
</pre>


<a name="cmakeadvanced.cached_variables"></a>
<h3><code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code> revisited</h3>

<p>
The <code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code> macro is responsible
for setting up cached variables and has to invoked before the
<code>PROJECT</code> call:
<pre class="cmake">
FIND_PACKAGE(deal.II 9.3.0 REQUIRED)

DEAL_II_INITIALIZE_CACHED_VARIABLES()

PROJECT(myproject)
</pre>
The macro will set an uninitialized <code>CMAKE_BUILD_TYPE</code> variable
to the the build type of deal.II, i.e. <code>DEAL_II_BUILD_TYPE</code>. If
<code>CMAKE_BUILD_TYPE</code> is specified it will automatically be reset
if the given value is unsupported by the deal.II installation (i.e., if it
is not equal to <code>Debug</code>, <code>Release</code>, or
<code>DebugRelease</code>).
</p>
<p>
Furthermore, this macro sets the C++ compiler to the one used for compiling
the deal.II library. The variables <code>CMAKE_CXX_FLAGS</code>,
<code>CMAKE_CXX_FLAGS_DEBUG</code>, and
<code>CMAKE_CXX_FLAGS_RELEASE</code> will be initialized with the empty
string.
</p>

<p>
Note: If you wish to override the flags and definitions set by the
<code>DEAL_II_SETUP_TARGET</code> macro you have to override the
corresponding <code>DEAL_II_*</code> variable instead. See the
documentation of <a
href="#cmakeadvanced.setup_target"><code>DEAL_II_SETUP_TARGET</code></a>
for further details.
</p>

<a name="cmakeadvanced.properties"></a>
<h3>Customizing include directories and compile definitions</h3>

<p>
You can specify custom include directories and compile definitions prior to
a target definition on a per directory basis (have a look at the <a
href="http://cmake.org/cmake/help/v2.8.8/cmake.html">CMake
documentation</a> for further details):

<pre class="cmake">
INCLUDE_DIRECTORIES(include1 include2)

ADD_DEFINITIONS(-DFOO -DBAR="BAZ")

ADD_EXECUTABLE(...) # or ADD_LIBRARY(...)
</pre>
</p>

<a name="cmakeadvanced.external_libraries"></a>
<h3>External libraries</h3>

<p>
For external libraries that provide a CMake project configuration or where
a CMake find module is available, including this external library in your
project is more or less straightforward. E.g. to require an external
project "foo" at least of version 8.0 write:
<pre class="cmake">
FIND_PACKAGE(foo 8.0 REQUIRED)
</pre>
Alternatively, the version number and <code>REQUIRED</code> keyword can be
omitted. Depending on the external library, the project configuration or
find macro will usually define variables like <code>FOO_INCLUDE_DIRS</code>
and <code>FOO_LIBRARIES</code> that can be directly used in your
<code>CMakeLists.txt</code> file:

<pre class="cmake">
INCLUDE_DIRECTORIES(${FOO_INCLUDE_DIRS})

ADD_EXECUTABLE(mycode mycode.cc)
DEAL_II_SETUP_TARGET(mycode)

TARGET_LINK_LIBRARIES(mycode ${FOO_LIBRARIES})
</pre>
The first statement will set up the include directories for the following
targets as explained above. The last statement with
<code>TARGET_LINK_LIBRARIES</code> will <i>add</i> the libraries in the
<code>FOO_LIBRARIES</code> variable to the link interface of the target
<code>mycode</code>.
</p>

<a name="cmakeadvanced.run"></a>
<h3>The "run" target revisited</h3>

<p>The simple run statement as explained <a
href="#cmakesimple.run">above</a> will run the generated executable in the
build directory. Sometimes it is more desirable to run the executable in a
dedicated <code>run</code> directory within in the build directory which is
a copy of a skeleton <code>run</code> folder from the source directory:

<pre class="cmake">
# Copy folder run from the source to the build directory:
FILE(COPY ${CMAKE_SOURCE_DIR}/run DESTINATION ${CMAKE_BINARY_DIR})

ADD_EXECUTABLE(mycode mycode.cc)
SET_PROPERTY(TARGET mycode
  PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run
  )
ADD_CUSTOM_TARGET(run
  COMMAND mycode
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
  )
</pre>
Here, we modify the <code>RUNTIME_OUTPUT_DIRECTORY</code> property of our
target so that the executable is linked inside our designated
<code>run</code> folder, so that it is conveniently available as an
executable inside the run folder. Furthermore, we specify a
<code>WORKING_DIRECTORY</code> for the <code>run</code> target, so that
<code>make run</code> invokes the executable inside the intended run
directory.
</p>

<a name="cmakeadvanced.install"></a>
<h3>Install a project</h3>

<p>If you want the <code>make install</code> to install your project to
<code>CMAKE_INSTALL_PREFIX</code> (that may be set on command line or in
the cache during the configuration stage), add appropriate
<code>INSTALL</code> statements. To install e.g. a project consisting of a
library and an executable as well as a run folder:

<pre class="cmake">
# [...] all the target definitions

INSTALL(TARGETS mylib DESTINATION lib)
INSTALL(TARGETS mycode DESTINATION bin)

INSTALL(DIRECTORY run DESTINATION share/mycode/run)
</pre>

<a name="cmakeauto"></a>
<h2>Autopilot style CMakeLists.txt</h2>

<p>
  If you want a make interface similar to the deal.II library and
  its tutorial, namely maker targets for debug and release
  versions, running the code and cleaning, the easiest way to
  write a <code>CMakeLists.txt</code> file may be to use
  an "autopilot" style macro. Here is a minimalistic example for the
  step-1 tutorial program (<a href="CMakeLists.txt.sample2"
			      target="_top">plain text</a> version) that can be used for simple
  projects:
</p>

<pre class="cmake">
FIND_PACKAGE(deal.II 9.3.0 REQUIRED
  HINTS
    ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
    # You can specify additional hints for search paths here, e.g.
    # $ENV{HOME}/workspace/deal.II
)

# Set the name of the project and target:
SET(TARGET "step-1")

# Declare all source files the target consists of:
SET(TARGET_SRC
  step-1.cc
  # You can specify additional files here!
)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
DEAL_II_INITIALIZE_CACHED_VARIABLES()
PROJECT(${TARGET} CXX)
DEAL_II_INVOKE_AUTOPILOT()
</pre>


      This <code>CMakeLists.txt</code> is intended for use with a small
      project and <i>in-source</i> build (i.e., one does not create a separate
      build directory as we recommend for the <acronym>deal.II</acronym> build
      in the <a href="../readme.html#configuration" target="_body">readme
      file</a>). Using this input file, you can run <code>cmake</code> in the
      source directory as follows:

<pre class="sample">
$ cd step-1
$ cmake .

[...]
###
#
#  Project  step-1  set up with  deal.II-8.3  found at
#      /usr
#
#  CMAKE_BUILD_TYPE:          Debug
#
#  You can now run
#       $ make                - to compile and link the program
#       $ make run            - to (compile, link and) run the program
#
#       $ make debug          - to switch the build type to 'Debug'
#       $ make release        - to switch the build type to 'Release'
#
#       $ make edit_cache     - to change (cached) configuration variables
#                               and rerun the configure and generate phases of CMake
#
#       $ make strip_comments - to strip the source files in this
#                               directory off the documentation comments
#       $ make clean          - to remove the generated executable as well as
#                               all intermediate compilation files
#       $ make runclean       - to remove all output generated by the program
#       $ make distclean      - to clean the directory from _all_ generated
#                               files (includes clean, runclean and the removal
#                               of the generated build system)
#       $ make info           - to view this message again
#
#  Have a nice day!
#
###
</pre>

      There are two additional configuration options (in addition to
      <code>TARGET</code> and <code>TARGET_SRC</code>) that can be set via
      variables before <code>DEAL_II_INVOKE_AUTOPILOT()</code> is called
      (<a href="CMakeLists.txt.sample3" target="_top">plain text</a> version):

<pre class="cmake">
# (Optional)
# Specify a list of files (file globs) that will be removed
# with the "make runclean" and "make distclean" targets.
# (If empty, sensible default values will be used.)
SET(CLEAN_UP_FILES
  # a custom list of globs, e.g. *.log *.vtk
)

# (Optional)
# A custom command line that should be invoked by "make run".
# (If empty, ./${TARGET} will be invoked.)
SET(TARGET_RUN
  # a custom command line, e.g. mpirun -np 2 ${TARGET}
)
</pre>


<a name="dealiiconfig"></a>
<h2>  <code>deal.IIConfig.cmake</code> </h2>

<p>
  Importing the deal.IIConfig.cmake file via <code>FIND_PACKAGE</code>
  will set the following variables and macros; all of the form
  <code>DEAL_II_*</code>:
</p>
<pre class="cmake">
#
# General package information:
#

DEAL_II_PACKAGE_NAME
DEAL_II_PACKAGE_VERSION     - the full package version string, e.g. "8.1.pre"
DEAL_II_PACKAGE_VENDOR
DEAL_II_PACKAGE_DESCRIPTION

DEAL_II_VERSION             - numerical version number (with "pre" and "rc?"
                              replaced by "0"), e.g. "8.2.0"
DEAL_II_VERSION_MAJOR       - the major number, e.g. "8"
DEAL_II_VERSION_MINOR       - the minor version number, e.g. "2"
DEAL_II_VERSION_SUBMINOR    - the minor version number, e.g. "0"

DEAL_II_GIT_BRANCH          - name of the local git branch of the source directory
DEAL_II_GIT_REVISION        - full sha1 revision of the current git HEAD
DEAL_II_GIT_SHORTREV        - short sha1 revision of the current git HEAD

DEAL_II_BUILD_TYPE          - the configured build type, e.g. "DebugRelease"
DEAL_II_BUILD_TYPES         - an all caps list of available configurations,
                              e.g. "DEBUG;RELEASE"

#
# Information about component locations:
#

DEAL_II_PATH
DEAL_II_SHARE_RELDIR
DEAL_II_DOCREADME_RELDIR
DEAL_II_DOCHTML_RELDIR
DEAL_II_EXAMPLES_RELDIR
DEAL_II_EXECUTABLE_RELDIR
DEAL_II_INCLUDE_RELDIR
DEAL_II_LIBRARY_RELDIR
DEAL_II_PROJECT_CONFIG_RELDIR

DEAL_II_BUILD_DIR             - true if deal.II was picked up from a build
                                dir, false if the configuration is from an installation

#
# Compiler and linker configuration
#

DEAL_II_CXX_COMPILER             - the compiler used to compile deal.II

DEAL_II_CXX_FLAGS                - compile flags for all configurations
DEAL_II_CXX_FLAGS_DEBUG          - _additional_ compile flags for the debug configuration
DEAL_II_CXX_FLAGS_RELEASE        - _additional_ compile flags for the release configuration

DEAL_II_LINKER_FLAGS             - link flags for all configurations
DEAL_II_LINKER_FLAGS_DEBUG       - _additional_ link flags for debug configuration
DEAL_II_LINKER_FLAGS_RELEASE     - _additional_ link flags for release configuration

DEAL_II_USER_DEFINITIONS         - compile definitions for all configurations
DEAL_II_USER_DEFINITIONS_DEBUG   - _additional_ compile definitions for debug configuration
DEAL_II_USER_DEFINITIONS_RELEASE - _additional_ compile definitions for release configuration

#
# Information about MPI runtime for the mpi implementation used in the
# deal.II library
#

DEAL_II_MPIEXEC
DEAL_II_MPIEXEC_NUMPROC_FLAG
DEAL_II_MPIEXEC_PREFLAGS
DEAL_II_MPIEXEC_POSTFLAGS


DEAL_II_STATIC_EXECUTABLE        - true if the link interface is set up to
                                   compile resulting executables statically

#
# Information about include directories and libraries
#

DEAL_II_INCLUDE_DIRS

DEAL_II_LIBRARIES_DEBUG   - a list of the full link interface for the debug configuration
DEAL_II_LIBRARIES_RELEASE - a list of the full link interface for the release configuration
DEAL_II_LIBRARIES         - full list of libraries with "debug" and "optimized" keywords

#
# Information about library targets
#

DEAL_II_TARGET_CONFIG  - the target config file

DEAL_II_TARGET_DEBUG   - the name of the debug target that is available after inclusion
                         of the target config file
DEAL_II_TARGET_RELEASE - the name of the release target
DEAL_II_TARGET         - full list of targets with "debug" and "optimized" keywords

#
# Feature configuration: The following booleans are set to "ON" or "OFF" depending
# on the current feature configuration:
#

DEAL_II_WITH_64BIT_INDICES
DEAL_II_WITH_ADOLC
DEAL_II_WITH_ARPACK
DEAL_II_WITH_ASSIMP
DEAL_II_WITH_BOOST
DEAL_II_WITH_COMPLEX_VALUES
DEAL_II_WITH_CUDA
DEAL_II_WITH_GINKGO
DEAL_II_WITH_GMSH
DEAL_II_WITH_GSL
DEAL_II_WITH_HDF5
DEAL_II_WITH_LAPACK
DEAL_II_WITH_METIS
DEAL_II_WITH_MPI
DEAL_II_WITH_MUPARSER
DEAL_II_WITH_OPENCASCADE
DEAL_II_WITH_P4EST
DEAL_II_WITH_PETSC
DEAL_II_WITH_SCALAPACK
DEAL_II_WITH_SLEPC
DEAL_II_WITH_SUNDIALS
DEAL_II_WITH_SYMENGINE
DEAL_II_WITH_THREADS
DEAL_II_WITH_TRILINOS
DEAL_II_WITH_UMFPACK
DEAL_II_WITH_ZLIB
</pre>

<hr />
<div class="right">
  <a href="http://validator.w3.org/check?uri=referer" target="_top">
    <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
  <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
    <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
</div>

</body>
</html>
